import {replaceWservice} from './common'
const CENTWE_SOURCE = "b_zhengquan_changjiang";
         // 开发环境屏蔽埋点-不建议
         window.weblog = {
          report: () => { },
          setConfig: () => { },
    
        };
        // 开发环境屏蔽skylking-不建议
        window.ClientMonitor = {
          registered: true,
          register: () => { },
          reportFrameErrors: () => { }
        }
export function rewriteJGYFunc() {
  // 添加全局方法做兼容;
  //重新重新搜索方法
  window.vaProtocol = {
    protocol: function (v) {
      const question = v.split("sendMsg^query=")[1];
      const params = {
        question: question,
      };
    },
  };
  //重写埋点

  window.hxmClickStat = function (t, i) {
    console.log("Stat1=", t, i);
  };

  window.hxmJumpPageStat = function (a, b, c) {
    console.log("Stat2=", a, b, c);
  };
  window.hxmEventStat = function (a, b) {
    console.log("Stat3=", a, b);
  };
  window.hxmJumpNativeStat = function (a, b, c) {
    console.log("Stat4=", a, b, c);
  };
  window.hxmOnceStat = function (a, b) {
    console.log("Stat5=", a, b);
  };
  window.hxmPageStat = function (a, b) {
    console.log("Stat6=", a, b);
  };
  window.hxmStat = function (a) {
    console.log("Stat7=", a);
  };
  // 重写查看更多跳转（问句：迈瑞医疗研报）
  // ai-stable-new.iwencai.com地址客户端直接访问获取不到数据，需要经过服务端转发一道
  window.JGY.showMoreClick = function (t, e) {
    console.log("showMoreClick");
  };
  /**
   * 行情跳转
   * @param {*} code 股票代码
   * @param {*} marketId 市场ID
   * @param {*} domain 领域：abs_基金领域、abs_指数领域、abs_股票领域、abs_港股领域、abs_美股领域
   * @param {*} i 点击的行号
   * @param {*} fundType 基金类型（平安定制化）
   */
  window.JGY.JumpHangqing = function (code, marketId, domain, i, fundType) {
    console.log(code, marketId, domain, i, fundType);
  };
  // 拦截analysis-show-more(问句：晶盛机电属于什么商业模式)
  window.JGY.clickTougudianpingMore = function (url) {
    console.log("clickTougudianpingMore--");
  };
  //重写咨讯列表跳转
  JGY.clickNewsList1Title = function (t) {
    const url = t.show_detail;
    window.JGY.jumpFun(url);
  };
  //重写a标签跳转
  window.JGY.ajumper = function (url) {
    console.log("ajumper--");
  };
  //重写诊股咨讯跳转
  window.JGY.clickList1Li = function (t) {
    console.log("clickList1Li--");
  };
  //重新表格描述跳转（问句：马云2，底部的网络印象点击不跳转）
  window.JGY.eventTableDescClick = function (rowIndex, index, url) {
    console.log(rowIndex, index, url);
    return;
  };
  window.JGY.clickTougudianpingMore = function (url) {
    window.JGY.jumpFun(url.url);
  };
  window.JGY.getBpointMoreUrl = function () {
    console.log("getBpointMoreUrl");
  };
  // table2点击事件（问句：迈瑞医疗研报）
  // ai-stable-new.iwencai.com地址客户端直接访问获取不到数据，需要经过服务端转发一道
  window.JGY.clickTable2Detail = function (obj) {
    console.log("clickTable2Detail");
  };
  window.JGY.jumpFun = function (a, b, c, d, e) {
   const url= replaceWservice(a)
   window.open(url)
    console.log("---window.JGY.jumpFun---", a, b, c, d, e);
  };

  window.getUserid = function () {
    console.log("getUserid 123");
    return "123";
  };
  window.JGY.title1Click=function(a,b){
    console.log("---window.JGY.title1Click---", a, b, c, d, e);
  }

  window.zhenguHref = {
    fenshiPage(hqcode, marketId, originCode) {
      console.log("fenshiPagefenshiPagefenshiPagefenshiPage");
    },
    iwencaiPage: function (query, domain) {
      //诊股更多跳b端
      const sourceString = CENTWE_SOURCE;
      let url;
      let source = CENTWE_SOURCE,
        userid = "wujf123",
        username = "namewujf123",
        version = "2.0",
        appVersion = "1.0";
      let appName = "changjiang";
      let urlroot = "https://ths8.iwencai.com/zxg/";

      //systemUtil.getBool(systemUtil.KEYS.ISOPEN_REPLACEURL)
      url = urlroot + "?q=" + encodeURIComponent(query) + "&showAd=false";
      url += `&source=${sourceString}`;
      if (domain) {
        url += "&querytype=" + encodeURIComponent(domain);
      }

      appName = appName + "_" + appVersion;
      url += "&app=" + appName;

      url =
        url +
        "&chanel=robot&source=" +
        source +
        "&userid=" +
        userid +
        "&username=" +
        username +
        "&version=" +
        version +
        "&app=" +
        appName;
      console.log("----------------open xuangugengduo");
      window.open(url);
    },
  };
}
